﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace SpriteWithXNA
{
    public class MySprite1
    {
        private Texture2D[] _texture2d;

        public Texture2D[] texture2d
        {
            get { return _texture2d; }
            set
            {
                _texture2d = value;
                _ntexture2d = _texture2d.Length;
            }
        }
        private int _ntexture2d;

        public int ntexture2d
        {
            get { return _ntexture2d; }
            set { _ntexture2d = value; }
        }

        private float _x;

        public float x
        {
            get { return _x; }
            set { _x = value; }
        }
        private float _y;

        public float y
        {
            get { return _y; }
            set { _y = value; }
        }

        private int _ngameTime;

        public int ngameTime
        {
            get { return _ngameTime; }
            set { _ngameTime = value; }
        }
        protected int _itexture2d;

        protected int itexture2d
        {
            get { return _itexture2d; }
            set { _itexture2d = value; }
        }

        //public MySprite(Texture2D[] _inputtexture2d, float _inputx, float _inputy)
        //{
        //    texture2d = _inputtexture2d;
        //    x = _inputx;
        //    y = _inputy;
        //    itexture2d = 0;
        //    ngameTime = 0;
        //}
        public virtual void Update(GameTime gameTime)
        {
            ngameTime++;
            if (ngameTime == 30)
            {
                Random r = new Random();
                _x = _x + r.Next(7) - 3;
                _y = _y + r.Next(11) - 5;
                _itexture2d = (_itexture2d + 1) % _ntexture2d;
                ngameTime = 0;
            }
        }

        public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(_texture2d[_itexture2d], new Vector2(_x, _y), Color.White);
            //g.DrawImage(_texture2d[_itexture2d], _x, _y);

        }
    }
}
